<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Jgpush_m extends FOX_Model
{

	function __construct ()
	{
		parent::__construct();
	}

    //计算站内总数
    public function count_tags_data_find()
    {
        $this->db->select('data_id');
        $this->db->from('tags_data');
        $total=$this->db->count_all_results();
        return $total;  
    }

    public function get_tags_data_list($limit,$start){
        $this->db->select('*');
        $this->db->from('tags_data');
        $this->db->limit($start,$limit);
        $this->db->order_by('data_update_time','desc');
        $this->db->order_by('data_add_time','desc');
        $query = $this->db->get();
        if($query->num_rows() > 0){
            return $query->result_array();
        }

    }

    public function get_tags_data_by_tags_id($data_id){
        $this->db->select('*');
        $query = $this->db->where('data_id',$data_id)->get('tags_data');
        return $query->row_array();
    }

    public function sava_tags_data($id,$data){

        $this->db->where('data_id',$id);
        $this->db->update('tags_data', $data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

    public function add_tags_data($data){

        $this->db->insert('tags_data',$data);
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }

    public function del_tags_data($id){
        $this->db->where($where)->delete('tags_data');
        return ($this->db->affected_rows() > 0) ? TRUE : FALSE;
    }
    
}
